import React, {useEffect, useState} from 'react';
import useTable from "@/cms/use/useTable";
import {Button, message, Modal, Space} from "antd";
import {orderStatusList, useRooms} from "@/pages/constant";
import useFilter from "@/cms/use/useFilter";

function Orders(props) {
    const {roomList} = useRooms({companyId:window.company_id})

    const {queryList,tableDOM} = useTable({
        columns:[
            {
                title:"订单来源",
                dataIndex:"source",
            },{
                title:"开始时间",
                dataIndex:"startTime"
            }, {
                title:"结束时间",
                dataIndex:"endTime"
            },{
                title:"订单金额",
                dataIndex:"price",
            },{
                title:"房间名",
                dataIndex:"roomId",
                render(text){
                    return roomList.find(item=>item.value === text)?.label
                }
            },
            {
              title:"订单状态",
              dataIndex: "status",
              render(text){
                  return orderStatusList.find(item=>item.value === text)?.label
              }
            },

        ],
        xhr:{
            query:"/app/orderList"
        },
        extraParams:{
            type:1
        }
    })
    const {FilterDOM} = useFilter({
        queryList,
        list:[
            {
                label:"房间",
                name:"roomId",
                type:"select",
                options:roomList
            },
            {
                label:"状态",
                name:"status",
                type:"select",
                options:orderStatusList
            }
        ]
    })

    return (
        <div>
            {FilterDOM}
            {tableDOM}
        </div>
    );
}

export default Orders;